package com.yanqu.road.server.cmd.activity.newyear2023.redpacket;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FireWorkProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.newyear2023.FireWorkActivity;
import com.yanqu.road.server.manager.activity.newyear2023.FireWorkMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C2_FIREWORK_ACTIVITY_CROSS_DATA_SYNC, desc = "登录同步信息")
public class CrossFireWorkSyncDataCmd extends CrossCommand {

    private int activityId;
    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        FireWorkProto.CrossFireWorkSyncUserDataReqMsg reqMsg = FireWorkProto.CrossFireWorkSyncUserDataReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        FireWorkActivity activity = FireWorkMgr.getFireWorkActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
            return;
        }

        activity.syncCrossUserData(serverId, userId);
    }

    @Override
    public void sendData() {

    }
}
